<%--
  查找用户信息
  输入问题答案，并将答案提交给userPasswordFind3.jsp处理
--%>
<%@ page import="com.dsj.dao.CustomerDao" %>
<%@ page import="com.dsj.entity.CustomerEntity" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>输入问题答案</title>
</head>
<body>
<%
    // 创建CustomerDao对象
    CustomerDao customerDao = new CustomerDao();
    // 设置请求的字符编码为utf-8
    request.setCharacterEncoding("utf-8");
    // 获取并去除name参数的前后空格
    String name = request.getParameter("name").trim();
    // 根据name查询CustomerEntity对象
    CustomerEntity user = customerDao.selectCustomerEntity(name);
    //如果用户存在，则保存在session中，否则设置提示信息“用户不存在，请重新输入！”，并跳转到找回密码页
    if (user == null) {
        session.setAttribute("message", "用户不存在，请重新输入！");
        response.sendRedirect(request.getContextPath() + "/pages/customer/userPasswordFind1.jsp");
    }
    session.setAttribute("user", user);
%>
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" height="100">
            <jsp:include   page="../common/head.jsp" flush="true" />
        </td>
    </tr>

    <tr>
        <td width="300" valign="top" bgcolor="#F5F5F5">
            <!--左侧01-->
            <jsp:include page="../common/left.jsp" flush="true" />
        </td>

        <td width="724" align="center" valign="top" bgcolor="#FFFFFF">

            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
                <tr>
                    <td bgcolor="#FFFFFF" align="center">
                        <img src="<%=request.getContextPath()%>/images/systemImages/fg2.jpg" width="752" height="45">
                        <%if(user==null||user.equals("")){%>
                        <p><strong>不存在此用户名称,请重新输入！！！</strong></p>
                        <meta http-equiv="refresh" content="2;URL=userPasswordFind1.jsp">
                        <%}else{%>
                        <p><strong>输入答案</strong></p>
                        <form name="form2" method="post" action="./userPasswordFind3.jsp" onSubmit="return checkEmpty(from2)">
                            <table width="298"  border="0" cellspacing="0" cellpadding="0" bordercolor="#FFFFFF" bordercolordark="#819BBC" bordercolorlight="#FFFFFF">
                                <tr>
                                    <td width="105" height="35">
                                        <div align="right">问题:</div></td>
                                    <td width="187"><div align="left">
                                        <input type="hidden" name="name" value="<%=user.getUserName()%>">
                                        <input type="hidden" name="question" value="<%=user.getPasswordQuestion()%>">
                                        <%=user.getPasswordQuestion()%>
                                    </div></td>
                                </tr>
                                <tr>
                                    <td width="105" height="35">
                                        <div align="right">答案:</div></td>
                                    <td width="187">
                                        <div align="left">
                                            <input type="text" name="result">
                                        </div></td>
                                </tr>
                            </table>
                            <br>
                            <input type="image" class="input1"  src="<%=request.getContextPath() %>/images/systemImages/save.jpg" width="51" height="20">&nbsp;&nbsp;
                            <a href="#" onClick="javascript:form2.reset()"><img src="<%=request.getContextPath() %>/images/systemImages/clear.gif"></a>	&nbsp;&nbsp;
                            <a href="#" onClick="javasrcipt:history.go(-1)"><img src="<%=request.getContextPath() %>/images/systemImages/back.gif"></a>
                        </form>
                        <%}%>
                    </td>
                </tr>
            </table>

        </td>

    <tr>
        <td colspan="2">
            <jsp:include page="../common/statusBarNavigation.jsp"
                         flush="true" />
        </td>
    </tr>
</table>

<script language="javascript">
    function checkEmpty(form){
        for(i=0;i<form.length;i++){
            if(form.elements[i].value==""){
                alert("表单信息不能为空");
                return false;
            }
        }
    }
</script>
</body>
</html>
